let container = document.querySelector('.container')
function rander(data, el) {
    //     let domStr = ''
    //     data.forEach(item => {
    //         let regExp = /(?<=imgurl=)[^'"]*/
    //         let result = item.productImg2.match(regExp)
    //         domStr += `<li>
    //     <img src=${result[0]} alt="" width="150">
    //     <b>${item.productName}</b>
    // </li>`
    //     })
    //     el.innerHTML = domStr
    //     console.log(data)
    data.forEach(item => {
        let li = document.createElement('li')
        li.setAttribute('id',item.productId)
        let regExp = /(?<=imgurl=)[^'"]*/
        let result = item.productImg2.match(regExp)
        let domStr = `<img src=${result[0]} alt="" width="150">
                            <h4>${item.productName}</h4>
                            <span>${item.productFrom}|${item.productTime}</span>
                            <span>${item.productComCount}</span>`
        li.innerHTML = domStr
        el.appendChild(li)
    })
}
function getData(pageid = 0) {
    fetch(`http://chst.vip:1234/api/getmoneyctrl?pageid=${pageid}`)
        .then(body => body.json())
        .then(res => {
            rander(res.result, container)
        })
}
getData()
let pageid = 1;
lazyLoad(function () {
    pageid++
    if (pageid > 14) {
        alert('Not Found')
        return
    }
    getData(pageid)
}, 100)  

// 请求首页数据
function setUrl() {
    // 请求首页数据
    let ul = document.querySelector('ul')
    ul.addEventListener('click', function (e) {
            let _this = e.path[1]
            let id = _this.getAttribute('id')
            // let name = $(_this).find('p').text()
            console.log(id)
            location.href = 'xq.html?id='+id
    })
}
setUrl()